/*
 *  Licensed to the Apache Software Foundation (ASF) under one
 *  or more contributor license agreements.  See the NOTICE file
 *  distributed with this work for additional information
 *  regarding copyright ownership.  The ASF licenses this file
 *  to you under the Apache License, Version 2.0 (the
 *  "License"); you may not use this file except in compliance
 *  with the License.  You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing,
 *  software distributed under the License is distributed on an
 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *  KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations
 *  under the License.
 */
package org.apache.causeway.applib.services.publishing.spi;

import org.apache.causeway.applib.services.command.Command;
import org.apache.causeway.commons.having.HasEnabling;

/**
 * Part of the <i>Publishing SPI</i>. A component to receive {@link Command}s
 * (with publishing enabled) that just completed.
 *
 * @since 2.0 {@index}
 */
public interface CommandSubscriber extends HasEnabling {

    /**
     * Notifies that the command will be published, and has transitioned to {@link org.apache.causeway.applib.services.command.Command.CommandPublishingPhase#READY}.
     *
     * <p>
     *     This is an opportunity for implementations to process the command,
     *     for example to persist an initial representation of it.
     * </p>
     */
    void onReady(Command command);

    /**
     * Notifies that the command has started to execute, and has transitioned to {@link org.apache.causeway.applib.services.command.Command.CommandPublishingPhase#STARTED}.
     *
     * <p>
     *     This is an opportunity for implementations to process the command,
     *     for example to update any persisted representation of it.
     * </p>
     */
    void onStarted(Command command);


    /**
     * Notifies that the command has completed and has transitioned to {@link org.apache.causeway.applib.services.command.Command.CommandPublishingPhase#COMPLETED}
     *
     * <p>
     *     This is an opportunity for implementations to process the command,
     *     for example to update any persisted representations of it.
     * </p>
     */
    void onCompleted(Command command);

}
